package tju.mic.medicine.ws.repo;


import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import tju.mic.medicine.ws.models.SysUserRole;

/**
 *
 * @author tjusnow
 */
public interface SysUserRoleRepository extends CrudRepository<SysUserRole,Long>{
    
    @Query("select a from SysUserRole a where a.user.id = ?1 order by a.id")
    public List<SysUserRole> getByUserId(Long userId);
    
    @Query("select a from SysUserRole a where a.role.id = ?1 order by a.id")
    public List<SysUserRole> getByRoleId(Long roleId);

    @Query("select a from SysUserRole a where a.user.id = ?1 and a.role.id = ?2 order by a.id")
    public List<SysUserRole> getByUserIdRoleId(Long userId, Long roleId);
}
